package LocalTime;


import org.junit.Test;

import java.time.*;

/**
 * @author 李泽伟
 */
public class Main {
    public static void main(String[] args) {
        // LocalTime LocalDate LocalDateTime
        // 静态方法now() 2022-10-18
        //14:57:34.781568200
        //2022-10-18T14:57:34.782566300
        LocalTime now = LocalTime.now();
        LocalDate date = LocalDate.now();
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(date);
        System.out.println(now);
        System.out.println(localDateTime);
        //get获取相关属性
        System.out.println(localDateTime.getSecond());
        System.out.println(localDateTime.getDayOfMonth());
        //with设置相关属性
        System.out.println(localDateTime.withDayOfMonth(1));
        //相关属性plus加上、减去minus
    }

    @Test
    public void test(){
        //now():获取格林威治时间
        Instant now = Instant.now();
        //2022-10-18T07:07:35.499095400Z  + 8h
        System.out.println(now);
        //时间偏移量ZoneOffset.ofHours() 差8个小时
        //2022-10-18T15:10:10.370991600+08:00
        OffsetDateTime offsetDateTime = now.atOffset(ZoneOffset.ofHours(8));
        System.out.println(offsetDateTime);
    }
}
